package com.yyy.lambda;

import java.util.Objects;
import java.util.concurrent.Callable;

public class TestCallable {

    public static void main(String[] args) throws Exception {


        System.out.println(getResult("ok", callable));
        System.out.println(getResult("ok2", callable));
    }

    static Callable<String> callable = () -> {
        return "这是一个回调函数";
    };


    public static String getResult(String str, Callable<String> callable) throws Exception {
        if (Objects.equals(str, "ok")) {
            return callable.call();
        } else {
            return "error";
        }
    }
}
